<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./templates/masterLayout.xhtml">

            <ui:define name="content">
                <c:if test="${shoppingCartManagedBean.checkexistCart()==true}">
                    <div class="body">
                        <h:form>
                            <h1><h:outputText value="List"/></h1>
                            <h:dataTable value="#{shoppingCartManagedBean.shoppingCartItems}" var="item" border="0">
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="ProductID"/>
                                    </f:facet>
                                    <h:outputText value="#{item.productID}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="ProductName"/>
                                    </f:facet>
                                    <h:outputText value="#{item.productName}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Image"/>
                                    </f:facet>
                                    <p:graphicImage value="#{item.image}" width="100px" height="100px"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="UnitPrice"/>
                                    </f:facet>
                                    <h:outputText value="#{item.unitPrice}">
                                    </h:outputText>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Quantity" />
                                    </f:facet>
                                    <p:inputText value="#{item.amount}" style="width:60px; height: 15px;" maxlength="10"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Rating" />
                                    </f:facet>
                                    <h:outputText value="#{item.rating}" style="width:60px; height: 15px;" />
                                    <f:facet name="footer">
                                        <b><h5><h:outputText value="Sub Total: " /></h5></b>
                                    </f:facet>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">
                                        <h:outputText value="Total" />
                                    </f:facet>
                                    <h:outputText value="#{item.value}" style="width:60px; height: 15px;" />
                                    <f:facet name="footer">
                                        <h:outputText value="#{shoppingCartManagedBean.subTotal}"/>
                                    </f:facet>
                                </h:column>
                                <h:column>
                                    <p:commandLink action="/Shoppingcart" actionListener="#{shoppingCartManagedBean.removeItemProductInCart}" ajax="false" >
                                        <p:graphicImage value="resources/images/btn_remove.png"   styleClass="morenews"/>
                                        <f:param value="#{item.productID}" name="proID"/>
                                    </p:commandLink>
                                    <p:commandLink action="/Shoppingcart" actionListener="#{shoppingCartManagedBean.editCart}" ajax="false">
                                        <p:graphicImage value="resources/images/btn_update-1.png"   styleClass="morenews"/>
                                    </p:commandLink>
                                </h:column>

                            </h:dataTable>
                        </h:form>
                        <div align="right" style="right: 20px; padding-bottom: 10px; padding-left: 70%; padding-top: 0px" >
                            <h:form>
                                <p:commandLink action="/checkout" ajax="false">
                                    <p:graphicImage value="resources/images/btn_checkout.png"/>
                                </p:commandLink>
                            </h:form>
                        </div>
                        <div class="clr"></div>
                    </div>
                </c:if>
                <c:if test="${shoppingCartManagedBean.checkexistCart()==false}">
                    <div class="body">
                        <h2><h:outputText value="Hien Tai khong co san pham nao"/></h2>
                        <div class="clr"></div>
                    </div>
                </c:if>
            </ui:define>


        </ui:composition>

    </body>
</html>
